package com.slipper.system.scheduled.front;

import com.slipper.common.bo.Result;
import com.slipper.common.util.ResultUtil;
import com.slipper.system.api.schedule.bo.ScheduleBO;
import com.slipper.system.api.scheduled.service.IScheduledSv;
import com.slipper.system.scheduled.ScheduledUtil;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ScheduledSv implements IScheduledSv {
    @Override
    public Result<?> run(ScheduleBO bo) {
        ScheduledUtil.run(bo);
        return ResultUtil.successResult("执行成功！");
    }

    @Override
    public Result<?> resumeJob(ScheduleBO bo) {
        ScheduledUtil.resumeJob(bo.getId());
        return ResultUtil.successResult("恢复调度成功！");
    }

    @Override
    public Result<?> pauseJob(ScheduleBO bo) {
        ScheduledUtil.pauseJob(bo.getId());
        return ResultUtil.successResult("停止调度成功！");
    }

    @Override
    public Result<?> createScheduleJob(ScheduleBO bo) {
        ScheduledUtil.createScheduleJob(bo);
        return ResultUtil.successResult("创建调度成功！");
    }

    @Override
    public Result<?> deleteScheduleJob(ScheduleBO bo) {
        ScheduledUtil.deleteScheduleJob(bo.getId());
        return ResultUtil.successResult("删除调度成功！");
    }
}
